package com.azusa.xbiao.entity;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Table(name = "goods")
public class Goods {
    private int id;
    private String title;
    private String intro;
    private BigDecimal price;
    private Integer count;
    private Integer look;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date publishTime;
    private String commoditPictureId;
    private String commoditUrl;
    private String shopName;
    private Date releaseDate;
    private String sales;
    private boolean userCollect = false;
    private String type;

    @Id
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "title", nullable = false, length = 255)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Basic
    @Column(name = "intro", nullable = true, length = 255)
    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    @Basic
    @Column(name = "price", nullable = false, precision = 2)
    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    @Basic
    @Column(name = "count", nullable = true)
    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    @Basic
    @Column(name = "look", nullable = true)
    public Integer getLook() {
        return look;
    }

    public void setLook(Integer look) {
        this.look = look;
    }

    @Basic
    @Column(name = "publish_time", nullable = true)
    public Date getPublishTime() {
        return publishTime;
    }

    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }

    @Basic
    @Column(name = "commodit_picture_id", nullable = true, length = 255)
    public String getCommoditPictureId() {
        return commoditPictureId;
    }

    public void setCommoditPictureId(String commoditPictureId) {
        this.commoditPictureId = commoditPictureId;
    }

    @Basic
    @Column(name = "commodit_url", nullable = true, length = 255)
    public String getCommoditUrl() {
        return commoditUrl;
    }

    public void setCommoditUrl(String commoditUrl) {
        this.commoditUrl = commoditUrl;
    }

    @Basic
    @Column(name = "shop_name", nullable = true, length = 255)
    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    @Basic
    @Column(name = "release_date", nullable = true)
    public Date getReleaseDate() {
        return releaseDate;
    }

    public void setReleaseDate(Date releaseDate) {
        this.releaseDate = releaseDate;
    }

    @Basic
    @Column(name = "sales", nullable = true, length = 255)
    public String getSales() {
        return sales;
    }

    public void setSales(String sales) {
        this.sales = sales;
    }

    @Transient
    public boolean isUserCollect() {
        return userCollect;
    }

    public void setUserCollect(boolean userCollect) {
        this.userCollect = userCollect;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Goods goods = (Goods) o;

        if (id != goods.id) return false;
        if (title != null ? !title.equals(goods.title) : goods.title != null) return false;
        if (intro != null ? !intro.equals(goods.intro) : goods.intro != null) return false;
        if (price != null ? !price.equals(goods.price) : goods.price != null) return false;
        if (count != null ? !count.equals(goods.count) : goods.count != null) return false;
        if (look != null ? !look.equals(goods.look) : goods.look != null) return false;
        if (publishTime != null ? !publishTime.equals(goods.publishTime) : goods.publishTime != null) return false;
        if (commoditPictureId != null ? !commoditPictureId.equals(goods.commoditPictureId) : goods.commoditPictureId != null)
            return false;
        if (commoditUrl != null ? !commoditUrl.equals(goods.commoditUrl) : goods.commoditUrl != null) return false;
        if (shopName != null ? !shopName.equals(goods.shopName) : goods.shopName != null) return false;
        if (releaseDate != null ? !releaseDate.equals(goods.releaseDate) : goods.releaseDate != null) return false;
        if (sales != null ? !sales.equals(goods.sales) : goods.sales != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (title != null ? title.hashCode() : 0);
        result = 31 * result + (intro != null ? intro.hashCode() : 0);
        result = 31 * result + (price != null ? price.hashCode() : 0);
        result = 31 * result + (count != null ? count.hashCode() : 0);
        result = 31 * result + (look != null ? look.hashCode() : 0);
        result = 31 * result + (publishTime != null ? publishTime.hashCode() : 0);
        result = 31 * result + (commoditPictureId != null ? commoditPictureId.hashCode() : 0);
        result = 31 * result + (commoditUrl != null ? commoditUrl.hashCode() : 0);
        result = 31 * result + (shopName != null ? shopName.hashCode() : 0);
        result = 31 * result + (releaseDate != null ? releaseDate.hashCode() : 0);
        result = 31 * result + (sales != null ? sales.hashCode() : 0);
        return result;
    }

    @Basic
    @Column(name = "type", nullable = true, length = 255)
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
